package com.junxonline.instant.admin.controller.monitor;

import com.junxonline.instant.dao.entity.vo.monitor.ApplicationVO;
import com.junxonline.instant.admin.zookeeper.ZookeeperClient;
import com.junxonline.instant.common.annotation.OperationLog;
import com.junxonline.instant.common.entity.common.CommonResult;
import com.junxonline.instant.common.enumeration.OperationEnum;
import lombok.extern.log4j.Log4j2;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 应用监控Controller
 *
 * @author JunX
 * @date 2022-06-15
 */
@Log4j2
@RestController
@RequestMapping(value = "/monitor/application")
public class ApplicationController {

    @Autowired
    private ZookeeperClient zookeeperClient;

    /**
     * 查询应用列表
     *
     * @param vo 请求参数
     * @return CommonResult
     */
    @RequiresPermissions(value = "monitor:application:query")
    @OperationLog(label = "应用监控-查询列表", type = OperationEnum.QUERY)
    @PostMapping(value = "/queryList")
    public CommonResult queryList(@RequestBody(required = false) ApplicationVO vo) {
        return CommonResult.success(zookeeperClient.getServerNodes(vo));
    }

}
